C#_C#彩色图片灰度化算法实例,本文实例讲述了C#彩色图片灰
g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height), 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);
{
//using the grayscale color matrix
new float[] {.11f, .11f, .11f, 0, 0},
//draw the original image on the new image
//create some image attributes
System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(
Graphics g = Graphics.FromImage(newBitmap);
});
Bitmap newBitmap = new Bitmap(original.Width, original.Height);
public static Bitmap MakeGrayscale(Bitmap original)
复制代码 代码如下:
//create a blank bitmap the same size as original
new float[] {0, 0, 0, 1, 0},
new float[] {.3f, .3f, .3f, 0, 0},
//set the color matrix attribute
主要功能代码如下:
//get a graphics object from the new image
new float[][]
attributes.SetColorMatrix(colorMatrix);
//create the grayscale ColorMatrix
new float[] {.59f, .59f, .59f, 0, 0},
//dispose the Graphics object
System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();
{
new float[] {0, 0, 0, 0, 1}
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/c/6901.shtml
